package com.lagou.blog.controller;

import com.lagou.blog.entity.ArticleEntity;
import com.lagou.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @GetMapping(value = "/page")
    public String findPage(@PageableDefault(size = 2)Pageable pageable, Model model){
        Page<ArticleEntity> page = articleService.findPage(pageable);
        model.addAttribute("page",page);
        return "client/index";
    }
}
